package org.xyf.gateway;


import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.xyf.common.utils.JwtUtils;

import java.util.List;


@SpringBootApplication
@EnableDiscoveryClient
public class Main implements ApplicationRunner {

    private Logger logger = LoggerFactory.getLogger(Main.class);

    @Resource
    private DiscoveryClient discoveryClient;

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<ServiceInstance> imServices = discoveryClient.getInstances("IMService");
        logger.info("imServices size is : {}",imServices.size());
        //生成便于测试的jwt
        String testJwt = JwtUtils.generateToken("xyf");
        logger.info("测试jwt : {} ",testJwt);
    }
}